<template>
  <div class="no-permission">
    <div class="no-permission-content">
      <div class="icon-wrapper">
        <el-icon class="no-permission-icon" :size="120">
          <Lock />
        </el-icon>
      </div>
      <h1 class="title">访问被拒绝</h1>
      <p class="description">抱歉，您没有权限访问此页面</p>
      <div class="actions">
        <el-button type="primary" @click="goBack">
          <el-icon><Back /></el-icon>
          返回上一页
        </el-button>
        <el-button @click="goHome">
          <el-icon><House /></el-icon>
          返回首页
        </el-button>
      </div>
      <div class="help-info">
        <p>如果您认为这是一个错误，请联系系统管理员</p>
        <p>当前用户：{{ currentUser }}</p>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { useAuthStore } from '@/stores/auth'
import { Lock, Back, House } from '@element-plus/icons-vue'

const router = useRouter()
const authStore = useAuthStore()
const currentUser = ref('')

onMounted(() => {
  // 获取当前用户信息
  const user = authStore.user
  currentUser.value = user ? user.username : '未知用户'
})

const goBack = () => {
  router.go(-1)
}

const goHome = () => {
  router.push('/')
}
</script>

<style scoped>
.no-permission {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}

.no-permission-content {
  text-align: center;
  background: white;
  padding: 60px 40px;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  max-width: 500px;
  width: 100%;
}

.icon-wrapper {
  margin-bottom: 30px;
}

.no-permission-icon {
  color: #f56c6c;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.title {
  font-size: 32px;
  font-weight: 700;
  color: #303133;
  margin: 0 0 16px 0;
  letter-spacing: -0.5px;
}

.description {
  font-size: 16px;
  color: #606266;
  margin: 0 0 40px 0;
  line-height: 1.6;
}

.actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 40px;
}

.actions .el-button {
  padding: 12px 24px;
  font-size: 14px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.help-info {
  border-top: 1px solid #ebeef5;
  padding-top: 24px;
  margin-top: 24px;
}

.help-info p {
  margin: 8px 0;
  font-size: 14px;
  color: #909399;
  line-height: 1.5;
}

.help-info p:first-child {
  color: #606266;
  font-weight: 500;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .no-permission-content {
    padding: 40px 20px;
    margin: 20px;
  }
  
  .title {
    font-size: 24px;
  }
  
  .actions {
    flex-direction: column;
    align-items: center;
  }
  
  .actions .el-button {
    width: 200px;
  }
}
</style> 